package org.grow.preview.infrastructure;

import org.grow.preview.domain.Bill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface JpaBill extends JpaRepository<Bill,Long> {

    Bill findByBillCode(String code);

    Bill queryByBillCode(String billCode);

    @Query("select b from Bill b " +
            "where b.billCode like ?1%")
    Bill searchByBillCode(String billCode);
    @Query(value = "select * from bill left join cargo on bill.bill_code=cargo.bill_code where cargo.cargo_code like ?1"
            ,nativeQuery = true)
    Bill searchByCargoCode(String cargoCode);
/**
* xieweig notes:@Query(value = "select * from #{#entityName} b where b.name=?1", nativeQuery = true)
 *        List<Book> findByName(String name);
*/
 /*   @Query(value= "?#{[0]}",nativeQuery = true)
    Bill searchByCargoCodeDynamic(String sql);*/
}
